from typing import List


class Solution:
    def maxSubArray(self, nums: List[int]) -> int:
        res = -2**31
        last = 0
        for i in range(len(nums)):
            last = nums[i] + max(0, last)
            res = max(last, res)
        return res
